/*****************		加载页面完成后定义		*****************************/
$(document).ready(function() {
	initcontractPhotoEditDlg();

	
	
	//contractPhotoEdit Dlg btn:update
	$("btn-contractPhotoEditDlg-ok").on('click',function(){
		
	});

});


//init edit contractPhotoEditDlg module
function initcontractPhotoEditDlg(){
	contractPhotoEditEzDlg=$('#div-contractPhotoEditDlg').dialog({    
		title: '合同照片编辑',    
		width: 800,    
		//height: 400,    
		closed: true,    
		cache: false,  
		top:20,
		//href: 'get_content.php',    
		modal: true,
		buttons:"#div-contractPhotoEdit-btns",
		onClose:function(){
			
		},
		onOpen:function(){
		},
		onBeforeOpen:function(){
			$('#btn-contractPhotoEditDlg-cancle').linkbutton({    
			    iconCls: 'icon-search',
			    onClick:function(){
			    	cancleContractPhotoEditDlg();
			    }
			});

			$('#btn-contractPhotoEditDlg-update').linkbutton({    
			    iconCls: 'icon-search',
			    onClick:function(){
			    	submitContractPhotoEditDlg();
			    }
			});

		}
	}); 
	console.log("in initcontractPhotoEditDlg function");
}

function cancleContractPhotoEditDlg(){
	console.log('hit  cancleContractPhotoEditDlg btn');
	contractPhotoEditEzDlg.dialog('close');
}


function submitContractPhotoEditDlg(){
	var str_urlUpdateContractPhotoByObj=contextPath+'/photo/operate/contractPhoto/update.json';
	console.log('hit  ok in ContractPhotoEditDlg btn');
	$('#form-contractPhotoEditDlg').form('submit', {    
   		url:str_urlUpdateContractPhotoByObj,    
	    onSubmit: function(obj_paramter){    
	        // do some check    
	        // return false to prevent submit;    
	        console.log(obj_paramter);
	        obj_paramter.text='xyz';
        	var isValid = $(this).form('validate');
				if (!isValid){
					$.messager.progress('close');	// 如果表单是无效的则隐藏进度条
				}
				return isValid;	// 返回false终止表单提交
	        //合同编号为空，不能保存

	    },    
	    success:function(str_json){
	    	var obj_json=JSON.parse(str_json); 
	        console.log(obj_json);
	        contractPhotoEditEzDlg.dialog('close');
	        var obj_contractPhoto=obj_json.data;
	        refreshSimplePhotoTableByContractPhoto(obj_contractPhoto);
	    }    
	});  




	/*var contractPhotoForm=nsl.serializeObject($('#form-contractPhotoEditDlg'));
	console.log(contractPhotoForm);

	//合同编号为空，不能保存
	if(!contractPhotoForm.contractId){
		alert("未选择合同编号。");
		return;
	}

	var postData={'contractPhoto':contractPhotoForm};
	$.ajax({  
	    url:urlUpdateContractPhotoByObj,// 跳转到 action  
	    data:postData,  
	    type:'post',  
	    dataType:'json', //预期服务器返回的数据类型。 
	    traditional: true,
	    success:function(result) {
	    	if(result.success){
	    		console.log("sucess.");
	    		refreshContractPhotoModule();
	    	}else{
	    		console.log("failed.");;
	    	}
	    },  
	     error : function(data) { 
	    	 //console.log(data);
	    	 alert("服务器错误，请于管理员联系:18639551912。");
	     }  
	});
	contractPhotoEditEzDlg.dialog('close');*/
}